﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class SkillTriggerMgr  {

    private static SkillTriggerMgr m_SkillTriggerMgr;
    public static SkillTriggerMgr Instance
    {
        get
        {
            if (m_SkillTriggerMgr == null)
                m_SkillTriggerMgr = new SkillTriggerMgr();
            return m_SkillTriggerMgr;
        }
    }
    Dictionary<string, ISkillTrigger> skillTriggers = new Dictionary<string, ISkillTrigger>();
    public ISkillTrigger CreateTrigger(string type, string args)
    {
        ISkillTrigger trigger;
        if (!skillTriggers.TryGetValue(type, out trigger))
        {
            Debug.LogError("no this trigger Type registered !!!");
        }
        trigger.Init(args);
        return trigger;
    }
    public void RegisterTriggerFactory<T>(string type, SkillTriggerFactory<T> factory) where T : ISkillTrigger, new()
    {
        skillTriggers.Add(type, factory.trigger);
    }
}
